<?php

namespace app\mec\controller;
use think\Controller;
use think\Db;
class Base extends Controller
{
    public function _initialize()
    {

        if(!session('mid')||!session('mname')){
            $this->redirect(url('mec/login/index'));
        }
        $level = Db::name('fenxiao')->where('fen_id',session('mid'))->value('fen_level');
        $this->assign([
            'username' => session('mname'),
            'portrait' => session('portrait'),
            'rolename' => $level,
            'theme'    => session('theme'),
        ]);
    }

    /**
     * place 三级联动
     * @return \think\response\Json
     */
    public function place()
    {
        $area = new \app\common\place\Area;
        $data = $area->area();
        return json($data);
    }
    public function getSonIDS()
    {
        $levelll = Db::name('fenxiao')->where('fen_id',session('mid'))->value('fen_level');
        $fids = session('mid');
        if($levelll == 1){
            $fids = Db::name('fenxiao')->where('fen_fid',session('mid'))->column('fen_id');
            if($fids){
                array_push($fids,session('mid'));
            }else{
                $fids = session('mid');
            }
        }
        return $fids;
    }

}